
FROM kasmweb/core-ubuntu-focal:develop
USER root
COPY ./src/ubuntu/sources.list /etc/apt/sources.list

ENV HOME /home/kasm-default-profile
ENV STARTUPDIR /dockerstartup
ENV INST_SCRIPTS $STARTUPDIR/install
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone
WORKDIR $HOME

######### Customize Container Here ###########


# Install Google Chrome
COPY ./src/ubuntu/install/chrome $INST_SCRIPTS/chrome/
RUN sed -i 's/\r$//' $INST_SCRIPTS/chrome/install_chrome.sh
RUN bash $INST_SCRIPTS/chrome/install_chrome.sh  && rm -rf $INST_SCRIPTS/chrome/

# Install Google Chrome Driver
RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
    && dpkg -i google-chrome-stable_current_amd64.deb || apt-get -fy install \
    && rm google-chrome-stable_current_amd64.deb

RUN wget -q https://registry.npmmirror.com/-/binary/chrome-for-testing/128.0.6613.119/linux64/chromedriver-linux64.zip && unzip chromedriver-linux64.zip && mv chromedriver-linux64/chromedriver /usr/local/bin/ && rm chromedriver-linux64.zip
# Path Add Chrome Driver Path
ENV PATH="/usr/local/bin:${PATH}"

# Update the desktop environment to be optimized for a single application
RUN cp $HOME/.config/xfce4/xfconf/single-application-xfce-perchannel-xml/* $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/
RUN cp /usr/share/backgrounds/bg_kasm.png /usr/share/backgrounds/bg_default.png
RUN apt-get remove -y xfce4-panel

# Security modifications
COPY ./src/ubuntu/install/misc/single_app_security.sh $INST_SCRIPTS/misc/
RUN sed -i 's/\r$//' $INST_SCRIPTS/misc/single_app_security.sh
RUN  bash $INST_SCRIPTS/misc/single_app_security.sh -t && rm -rf $INST_SCRIPTS/misc/
COPY ./src/common/chrome-managed-policies/urlblocklist.json /etc/opt/chrome/policies/managed/urlblocklist.json

# Setup the custom startup script that will be invoked when the container starts
#ENV LAUNCH_URL  http://kasmweb.com

COPY ./src/ubuntu/install/chrome/custom_startup.sh $STARTUPDIR/custom_startup.sh
RUN sed -i 's/\r$//' $STARTUPDIR/custom_startup.sh
RUN chmod +x $STARTUPDIR/custom_startup.sh

# Install Custom Certificate Authority
# COPY ./src/ubuntu/install/certificates $INST_SCRIPTS/certificates/
# RUN bash $INST_SCRIPTS/certificates/install_ca_cert.sh && rm -rf $INST_SCRIPTS/certificates/

ENV KASM_RESTRICTED_FILE_CHOOSER=1
COPY ./src/ubuntu/install/gtk/ $INST_SCRIPTS/gtk/
RUN sed -i 's/\r$//' $INST_SCRIPTS/gtk/install_restricted_file_chooser.sh
RUN bash $INST_SCRIPTS/gtk/install_restricted_file_chooser.sh

# Install OpenJDK-11-JDK
RUN apt-get update && apt-get install -y openjdk-11-jdk
# Install Python3.8
RUN apt-get install -y libmysqlclient-dev tzdata python3 python3-tk python3-dev python3-pip libpcre3 libpcre3-dev  uwsgi-plugin-python3

# Install Tesseract-OCR
RUN apt-get install -y tesseract-ocr

# Install  scrot
RUN apt-get install -y scrot

# Install allure
WORKDIR /software
RUN wget https://kkgithub.com/allure-framework/allure2/releases/download/2.30.0/allure-2.30.0.zip
RUN unzip allure-2.30.0.zip
RUN ln -s /software/allure-2.30.0/bin/allure /usr/bin/allure

######### End Customizations ###########

RUN chown 1000:0 $HOME
RUN sed -i 's/\r$//' $STARTUPDIR/set_user_permission.sh
RUN $STARTUPDIR/set_user_permission.sh $HOME

ENV HOME /home/kasm-user
WORKDIR $HOME
RUN mkdir -p $HOME && chown -R 1000:0 $HOME


WORKDIR  /app
COPY /psademo /app

RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple


